﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RaiderManagerBackend
{
    public static class Extensions
    {
        public static double ToGradePoint(this String str)
        {
            if (str == null)
                return 0;

            if (str.Length > 2)
            {
                throw new ArgumentException("The string was not a valid grade");
            }

            //TODO: We could insert a nice little regex statement here to verify it's a proper grade, or we can jsut rely on the switch statement to 
            //throw out improper grades.

            switch (str.ToUpper())
            {
                case "A":
                    return 4;
                case "A-":
                    return 11 / 3;
                case "B+":
                    return 10 / 3;
                case "B":
                    return 3;
                case "B-":
                    return 8 / 3;
                case "C+":
                    return 7 / 3;
                case "C":
                    return 2;
                case "C-":
                    return 5 / 3;
                case "D+":
                    return 4 / 3;
                case "D":
                    return 1;
                case "D-":
                    return 2 / 3;
                case "F":
                    return 0;
                default:
                    return 0;
            }
        }
    }
}
